package Thread;

public class ThreadDemo8 {

    static Object object = new Object();

    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(()->{
           synchronized (object){
               while (true){

               }
           }
        });
        Thread t2 = new Thread(()->{
            synchronized (object){
                System.out.println("t2");
            }
        },"猪猪侠");

        //创建这t1线程
        t1.start();

        //等待200ms让t1线程优先创建好
        Thread.sleep(200);

        //创建这t2线程
        t2.start();

        //等待200ms让t2线程优先创建好
        Thread.sleep(200);
        //查看t2线程的状态
        System.out.println("当先线程 "+t2.getName()+"的状态是"+t2.getState()+"状态");
    }
}
